package top.lauwen.selfservice;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;

import java.io.File;
import java.io.IOException;

public class Music extends Service {
    private MediaPlayer player;


    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
//        throw new UnsupportedOperationException("Not yet implemented");
        return null;
    }
    public void onStart(Intent intent,int startId){
        super.onStart(intent,startId);
//        initMediaPlayer();
        player = MediaPlayer.create(this,Uri.parse("/手机存储/Fade.mp3"));
        player.start();
    }
    public void onDestroy(){
        super.onDestroy();
        player.stop();
    }
//    private void initMediaPlayer(){
//        try{
//            File file = new File(Environment.getExternalStorageDirectory(),"Fade.mp3");
//            player.setDataSource();
//            player.prepare();
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }


}
